<?php

/**
 * @package		Joomla.Tutorials
 * @subpackage	Component
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 * @license		License GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access to this file
defined('_JEXEC') or die;

jimport('joomla.form.helper');

JFormHelper::loadFieldClass('list');

class JFormFieldSousserie extends JFormFieldList
{
	protected $type = 'sousserie';

	protected function getInput()
	{
    $onchange	= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
		$db = JFactory::getDBO();
		$query = $db->getQuery(true);
		$query->select('p.id as id, p.sous_serie as sous_serie');
		$query->from('#__glycophile_sousserie p');
	
		$db->setQuery((string)$query);
 
		$series = $db->loadObjectList();
		$options = array();
		if($series){
			foreach($series as $serie){
				$options[] = JHtml::_('select.option', $serie->id, $serie->sous_serie);
			}
		}
    
		$options = array_merge(parent::getOptions(), $options);
    $return = JHtml::_('select.genericlist', $options, $this->name, $onchange, 'value', 'text', $this->value, $this->value);
		return $return;
	}
}
